<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>站内消息</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<script src="resources/js/jquery-1.4.2.min.js" type="text/javascript"></script>
	<link  rel="stylesheet" href="resources/css/dlg.css" />
	
</head>
<body>
	<div id="msgbox">
		<div class="msg n">
			<div class="msgimg"><img src="demoimages/dogface2.gif" /></div>
			<p class="petname">蛋蛋-上海市-徐汇区</p>
			<p>&quot;今天晚上一起玩好吗&quot;</p>
			<p>8分钟前
				<span class="msgbtns">
					<input type="button" value="回复" class="btn2 btnreply" />
				</span>
			</p>
			
		</div>
		
		
		<div class="msg n">
			<div class="msgimg"><img src="demoimages/dogface2.gif" /></div>
			<p class="petname">蛋蛋-上海市-徐汇区</p>
			<p>&quot;今天晚上一起玩好吗&quot;</p>
			<p>8分钟前
				<span class="msgbtns">
					<input type="button" value="回复" class="btn2 btnreply" />
				</span>
			</p>
		</div>
		<div class="msg n">
			<div class="msgimg"><img src="demoimages/dogface2.gif" /></div>
			<p class="petname">蛋蛋-上海市-徐汇区</p>
			<p>&quot;今天晚上一起玩好吗&quot;</p>
			<p>8分钟前
				<span class="msgbtns">
					<input type="button" value="回复" class="btn2 btnreply" />
				</span>
			</p>
		</div>
	</div>
	
	<div class="pubbox" id="pubbox">
		<textarea name="replycontent"></textarea>
		<input type="button" value="发送" class="btnpub" />
		<!-- msgid 隐藏域放回复相关数据 -->
		<input type="hidden" name="msgid" value="" />
	</div>
	
	<div class="center">
		<input type="button" value="关闭" class="btn" onclick="window.parent.sitemsgdlg.hide();" />
	</div>
	<script type="text/javascript">
		$(function(){
			$("#msgbox .btnreply").click(function(){
				var $this= $(this);
				var $msg = $(this).parents(".msg");
				var $pubbox = $msg.next(".pubbox");
				if($pubbox.length==0){
					$pubbox= $("#pubbox").clone().removeAttr("id");
					$("[name=msgid]",$pubbox).val("1213");//给隐藏域赋值
					$msg.after($pubbox);
					$pubbox.show();
					$this.val("取消");
				}else{
					$pubbox.remove();
					$this.val("回复");
				}
			});
			$(".btnpub").live("click",function(){
				var $pubbox = $(this).parents(".pubbox");
				var msgid= $("[name=msgid]",$pubbox).val();//取到回复隐藏域值
				var replycontent = $("[name=replycontent]",$pubbox).val();
				//save ...
				$msg = $pubbox.prev(".msg");
				$("<p class=\"myreply\">我的回复：&quot;"+replycontent+"&quot;</p>").appendTo($msg);
				$(".btnreply",$msg).attr("disabled",true).val("已回复");
				$pubbox.remove();
			})
		});
	</script>
</body>
</html>
